package framework.util;

import org.junit.Test;
import sun.net.www.protocol.ftp.FtpURLConnection;

import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * @author 吴宇亮 on 2019/8/31 10:42
 */
public class _ResourcesUtil {

    /**
     * 获取resources下file的绝对路径
     * @param file resources目录下的路径+文件名，如：wsdl/mobilecodews.wsdl
     * @return 返回资源的绝对路径
     */
    public static String getAbsolutePath(String file){
        String path = _ResourcesUtil.class.getClassLoader().getResource(file).getPath();
        return path;
    }

    /**
     * 获取resources下file的URL
     */
    public static URL getURL(String file) throws MalformedURLException {
        String absolutePath = getAbsolutePath(file);
        URL url = new URL("file://" + absolutePath);
        return url;
    }


}
